<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>领奖纪录列表</title>
    <!--{include file='comm/comm_cal.tpl'}-->
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="ebsig_container">

    <!--{include file='comm/menu.tpl'}-->
    <div class="comm_content">

        <div  class="search-box">
            <form id="searchForm" name="searchForm" method="post" action="/quanliadmin/app/promotion/awardRecord.pscript?operFlg=2">
                <div style="position:relative">
                    <span>
                        领奖日期：
                        <input type="text" id="startDate" name="startDate" readonly="readonly" style="width: 120px;" />
                        ～
                        <input type="text" id="endDate" name="endDate" readonly="readonly" style="width: 120px;" />
                    </span>
                    <span>
                        领奖人手机号码：
                       <input type="text" id="mobile" name="mobile" style="width: 150px;" />
                    </span>

                    <span>
                        <input type="button" class="btn" value="查询" onclick="award.search();">&nbsp;&nbsp;
                        <input type="button" class="btn" value="重置" onclick="award.clear();">
                    </span>
                </div>
            </form>
        </div>

        <table id="flex" style="display:none"></table>

    </div>
</div>

<script type="text/javascript">

    $('#startDate').datetimepicker();
    $('#endDate').datetimepicker();

    $("#flex").flexigrid({
        type: "POST",
        url:"/invokingAjax-backend/promotion/awardRecord.ajax?operFlg=1&xjx=none",
        dataType: "json",
        colModel : [
                <!--{if $edit_permission}-->
            {display: "操作", width : 100, align: 'center'},
                <!--{/if}-->
            {display: "领奖人", width : 120, align: 'left'},
            {display: "领奖人手机号码", width : 120, align: 'left'},
            {display: "收货地址", width : 300, align: 'left'},
            {display: "身份证号码", width : 130, align: 'left'},
            {display: "奖品", width : 200, align: 'left'},
            {display: "领奖日期", width : 130, align: 'left'}
        ],
        buttons : [
            {name: "导出", bclass: "export", onpress : "award.awardexport"}
        ],
        sortname: "createTime", 
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true
    });

    var award = {
        search: function(){
            if($('#startDate').val()>$('#endDate').val()){
                E.alert('开始时间大于结束时间');
                return false;
            }
            var dt = $('#searchForm').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },
        clear: function(){
            $('#startDate').val('');
            $('#endDate').val('');
            $('#mobile').val('');
        },
        awardexport: function(){
            $('#searchForm').submit();
        },
        edit: function(pcustID){

            E.open('/quanliadmin/app/promotion/awardRecord.pscript?operFlg=3&pcustID='+pcustID);

        },
        load: function() {
            $("#flex").flexReload();
            E.popup.close();
        },

        openHTML : {

            awardEdit: function(receive_id){
                E.ajax_post({
                    url: '/invokingAjax-backend/promotion/awardRecord.ajax?operFlg=3',
                    data: {'receive_id':receive_id},
                    call: "award.openHTML.resultEdit"
                });
            },


            resultEdit:function(o){
                E.popup.open({
                    id:'awardEdit',
                    title: "领奖纪录修改", //弹出标题，不传则默认为“提示信息”【可选】
                    //content: h,    //显示内容（html代码），不传则默认为空【可选】
                    btnName: "提交", //“确认”按钮，不传则不显示
                    btnCall: "award.openHTML.awardCheck('"+o.receive_id+"')"//点击“确认”按钮触发的函数/方法
                });

                $('#receive_id').val(o.receive_id);
                $('#custName').val(o.custName);
                $('#a_mobile').val(o.mobile);
                $('#address').val(o.address);
                $('#identityCard').val(o.identityCard);
            },

            awardCheck:function(receive_id){

                $msg = '';

                if(E.isEmpty($('#custName').val())){
                    $msg += '领奖人不能为空<br/>';
                }

                if(!E.isMobile($('#a_mobile').val())){
                    $msg += '请输入正确手机号码<br/>';
                }

                if(E.isEmpty($('#address').val())){
                    $msg += '收货地址不能为空<br/>';
                }

                if($msg != ''){
                    E.alert($msg);
                    return false;
                }

                var dt = E.getFormValues('set_form');

                E.loadding.open();

                E.ajax_post({
                    url: '/invokingAjax-backend/promotion/awardRecord.ajax?operFlg=2',
                    data: {'dt':dt},
                    call: "award.openHTML.result"
                });

            },

            result: function(o){
                E.loadding.close();
                if(o.code == '200'){
                    E.alert(o.message,2,'award.load');

                }else{
                    E.alert(o.message);
                }
            }

        }

    }
</script>

<!--OPEN HTML-->
<div style="display: none">
    <div id="awardEdit">
        <form id="set_form">

            <input type='hidden'  name='receive_id' id='receive_id'>

                        <div class="input-group input-group-lg">
                            <span class="input-group-addon">领奖人：</span>
                            <input type="text" class="form-control" name='custName' id='custName'>
                        </div>

                    <div class="input-group input-group-lg">
                        <span class="input-group-addon">手机号码：</span>
                        <input type="text" class="form-control" name='a_mobile' id='a_mobile'>
                    </div>


                        <div class="input-group input-group-lg">
                            <span class="input-group-addon">收货地址：</span>
                            <input type="text" class="form-control" name="address" id="address">
                        </div>


                        <div class="input-group input-group-lg">
                            <span class="input-group-addon">身份证号：</span>
                            <input type="text" class="form-control" name='identityCard' id='identityCard'>
                        </div>
        </form>
    </div>
</div>

<!--end OPEN HTML-->

</body>
</html>